package main

import (
	"fmt"
	"harbor/src/models"
	"harbor/src/service"
)
const (
	HARBOR_URL="dockerhub.picclife.com"
	NewHARBOR_URL="10.137.194.231"

)
var NewUser = models.User{
	UserName: "admin",
	Password: "Harbor12345",
}

var OldUser = models.User{
	UserName: "yanxianhe",
	Password: "Qaz.12345",
}
func main() {
	//http.PostForm("https://10.111.80.2/c/login",
	//	url.Values{"principal": {"admin"}, "password": {"Harbor12345"}})
	//获取旧harbor所有project  api:https://10.111.80.2/api/projects
	harbor_proj_arr:=service.GetProject(HARBOR_URL)
	//获取新harbor所有project
	newharbor_proj_arr:=service.GetProject(NewHARBOR_URL)


	//判断项目，在新的Harbor创建项目
	//service.ContrastProj(newharbor_proj_arr,harbor_proj_arr,NewUser,NewHARBOR_URL)

	//根据老Harbor项目向新Harbor推项目成员
	//service.CheckUserInProject(harbor_proj_arr,OldUser,HARBOR_URL,NewHARBOR_URL,NewUser)
	//新harbor的register
	new_repositories:=service.GetRepositories(newharbor_proj_arr,NewHARBOR_URL)
	//旧harbor的register
	old_repositories:=service.GetRepositories(harbor_proj_arr,HARBOR_URL)
	//获取镜像tag，拼接完整镜像
	//api https://10.111.80.2/api/repositories/images_name/tags
	//旧harbor的images
	oldimages:= service.GetImages(old_repositories,HARBOR_URL)
	//新harbor的images
	newimages:= service.GetImages(new_repositories,NewHARBOR_URL)
	//全量同步
	//service.AllImageSync(newimages,oldimages,OldUser,NewUser,HARBOR_URL,NewHARBOR_URL)
	//同步差集镜像
	//service.ExceptImageSync(newimages,oldimages,OldUser,NewUser,HARBOR_URL,NewHARBOR_URL)
	for i,v:= range oldimages{
		fmt.Println("旧harbor",i,v)
	}
	//比对两个harbor slice，确认需要操作的镜像
	for i,v:= range newimages{
		fmt.Println("新harbor",i,v)
	}
}
